package user_api

import (
	"ginBolg/global"
	"ginBolg/models/res"
	"ginBolg/service"
	"ginBolg/utils/jwt"
	"github.com/gin-gonic/gin"
)

func (UserApi) LogoutView(c *gin.Context) {
	_claims, _ := c.Get("claims")
	claims := _claims.(*jwt.CustomClaims)
	token := c.Request.Header.Get("token")

	err := service.ServiceApp.UserService.LogoutView(claims, token)
	if err != nil {
		global.Log.Error(err)
		res.Fail("注销失败", c)
		return
	}
	res.OkWithMessage("注销成功", c)
}
